﻿<UserControl x:Class="SMS.Views.Master.CustomerTransactionHistory"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             d:DesignHeight="300"
             d:DesignWidth="600"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
             xmlns:my="clr-namespace:SMS.Controls;assembly=SMS.Controls">

    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="1"
              HorizontalAlignment="Left"
              VerticalAlignment="Stretch">
            <Grid.RowDefinitions>
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <sdk:DataGrid AutoGenerateColumns="False"
                          ItemsSource="{Binding Path=TransactionList}"
                          Grid.ColumnSpan="3"
                          Name="dataGrid1">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Header="Date"
                                            Binding="{Binding Path=TransactionDate}" />
                    <sdk:DataGridTextColumn Header="Transaction Type"
                                            Binding="{Binding Path=CreditDebit}" />
                    <sdk:DataGridTextColumn Header="Amount"
                                            Binding="{Binding Path=Amount, StringFormat=N3}" />
                    <sdk:DataGridTextColumn Header="Running Balance"
                                            Binding="{Binding Path=RunningTotal, StringFormat=N3}" />
                    <sdk:DataGridTemplateColumn>
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <HyperlinkButton Content="Show Detail"
                                                 CommandParameter="{Binding Path=.}"
                                                 Command="{Binding Path=ShowDetailCommand}" />
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
            <Grid Grid.Row="1"
                  HorizontalAlignment="Right">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="4" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <TextBlock Text="Total Debit: "
                           Grid.Row="1" />
                <TextBlock Text="Total Credit: "
                           Grid.Row="2" />
                <TextBlock Text="Balance: "
                           Grid.Row="3" />
                <TextBox Text="{Binding Path=TotalDebit, StringFormat=N3}"
                         Width="100"
                         Grid.Row="1"
                         Grid.Column="2"
                         TextAlignment="Right" />

                <TextBox Text="{Binding Path=TotalCredit, StringFormat=N3}"
                         Width="100"
                         Grid.Row="2"
                         Grid.Column="2"
                         TextAlignment="Right" />
                <TextBox Text="{Binding Path=Balance, StringFormat=N3}"
                         Width="100"
                         Grid.Row="3"
                         Grid.Column="2"
                         TextAlignment="Right" />

            </Grid>
        </Grid>

        <StackPanel Grid.Row="3"
                    Margin="5"
                    Orientation="Horizontal">
            <TextBlock Text="Amount:" />
            <TextBox Text="{Binding Path=ReceiveAmount, Mode=TwoWay, StringFormat=N}"
                     TextAlignment="Right"
                     Margin="5,0"
                     Width="150" />
            <Button Content="Receive"
                    Command="{Binding Path=ReceiveCommand}" />
        </StackPanel>
        <my:ErrorControl HorizontalAlignment="Left"
                         Grid.Row="4"
                         Margin="5"
                         Name="errorControl1"
                         VerticalAlignment="Top" />
        <StackPanel Orientation="Horizontal"
                    Margin="5"
                    VerticalAlignment="Top">
            <TextBlock Text="Cusotmer: " />
            <my:SMSCustomer HorizontalAlignment="Left"
                            Margin="5,0"
                            Width="150"
                            SelectedCustomer="{Binding Path=SelectedMaster, Mode=TwoWay}" />
            <TextBlock Text="From"
                       Margin="5,0" />

            <sdk:DatePicker SelectedDate="{Binding Path=SelectedFromDate, Mode=TwoWay}" />
            <TextBlock Text="To"
                       Margin="5,0" />

            <sdk:DatePicker SelectedDate="{Binding Path=SelectedToDate, Mode=TwoWay}" />

            <Button Content="Show Transactions..."
                    Command="{Binding Path=LoadTransactionCommand}"
                    CommandParameter="ChildWindow"
                    VerticalAlignment="Center" />
        </StackPanel>
    </Grid>
</UserControl>
